package com.ss.android.push.window.oppo;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.widget.FrameLayout;

public class PushWindowScrollView extends FrameLayout {
    private a a;
    private int b;
    private VelocityTracker c;
    private int d;
    private int e;
    private float f;
    private float g;
    private float h;
    private int i;
    private boolean j;
    private int k;
    private boolean l;
    private int m;

    public PushWindowScrollView(Context arg3) {
        super(arg3);
        this.i = -1;
        this.j = false;
        this.l = false;
        this.m = 0;
        this.a();
    }

    public PushWindowScrollView(Context arg3, AttributeSet arg4) {
        super(arg3, arg4);
        this.i = -1;
        this.j = false;
        this.l = false;
        this.m = 0;
        this.a();
    }

    public PushWindowScrollView(Context arg3, AttributeSet arg4, int arg5) {
        super(arg3, arg4, arg5);
        this.i = -1;
        this.j = false;
        this.l = false;
        this.m = 0;
        this.a();
    }

    private void a() {
        ViewConfiguration v0 = ViewConfiguration.get(this.getContext());
        this.b = v0.getScaledTouchSlop();
        this.d = v0.getScaledMinimumFlingVelocity();
        this.e = v0.getScaledMaximumFlingVelocity();
        this.k = ((int) (this.getContext().getResources().getDisplayMetrics().density * 25f));
    }

    private int a(MotionEvent arg3, int arg4) {
        int v1 = -1;
        int v0 = arg3.findPointerIndex(arg4);
        if (v0 == v1) {
            this.i = v1;
        }

        return v0;
    }

    private void a(MotionEvent arg7) {
        int v2 = -1;
        int v0 = this.i;
        int v1 = this.a(arg7, v0);
        if (v0 != v2 && v1 != v2) {
            float v0_1 = arg7.getX(v1);
            float v2_1 = Math.abs(v0_1 - this.f);
            float v1_1 = arg7.getY(v1);
            float v3 = Math.abs(v1_1 - this.g);
            if (v3 > (((float) this.b)) && v3 > v2_1) {
                this.l = true;
                this.f = v0_1;
                this.g = v1_1;
                return;
            }

            if (v2_1 <= (((float) this.b))) {
                return;
            }

            this.j = true;
        }
    }

    private void b() {
        this.l = false;
        this.j = false;
        this.i = -1;
        if (this.c != null) {
            this.c.recycle();
            this.c = null;
        }
    }

    public boolean onInterceptTouchEvent(MotionEvent arg6) {
        boolean v0 = true;
        int v4 = -1;
        int v2 = arg6.getAction();
        if (v2 == 3 || v2 == 1) {
            label_10:
            this.b();
            v0 = false;
        } else {
            if (v2 != 0 && (this.j)) {
                this.b();
                return false;
            }

            switch (v2 & 255) {
                case 0: {
                    v2 = arg6.getActionIndex();
                    this.i = arg6.getPointerId(v2);
                    if (this.i == v4) {
                        break;
                    }

                    this.f = arg6.getX(v2);
                    float v2_1 = arg6.getY(v2);
                    this.g = v2_1;
                    this.h = v2_1;
                    this.l = false;
                    this.j = false;
                    break;
                }
                case 2: {
                    v2 = this.a(arg6, this.i);
                    if (this.i == v4) {
                        break;
                    }

                    arg6.getY(v2);
                    this.a(arg6);
                    break;
                }
            }

            if (!this.l) {
                if (this.c == null) {
                    this.c = VelocityTracker.obtain();
                }

                this.c.addMovement(arg6);
            }

            if (this.l) {
                return v0;
            }

            v0 = false;
        }

        return v0;
    }

    public boolean onTouchEvent(MotionEvent arg8) {
        float v0_2;
        int v0_1;
        boolean v0 = false;
        int v6 = -1;
        if (this.c == null) {
            this.c = VelocityTracker.obtain();
        }

        this.c.addMovement(arg8);
        switch (arg8.getAction() & 255) {
            case 0: {
                this.i = arg8.getPointerId(arg8.getActionIndex());
                v0_2 = arg8.getY();
                this.h = v0_2;
                this.g = v0_2;
                this.f = arg8.getX();
                break;
            }
            case 2: {
                if (!this.l) {
                    this.a(arg8);
                    if (!this.j) {
                    } else {
                        return v0;
                    }
                }
                if (!this.l) {
                    return true;
                }

                v0_1 = this.a(arg8, this.i);
                if (this.i == v6) {
                    return true;
                }

                v0_2 = arg8.getY(v0_1);
                float v2_2 = this.g - v0_2;
                this.g = v0_2;
                v0_2 = (((float) this.m)) + v2_2;
                this.f += v0_2 - (((float) (((int) v0_2))));
                this.m = ((int) v0_2);
                if (this.a == null) {
                    return true;
                }

                this.a.a(v2_2);
                break;
            }
            case 1:
            case 3: {
                if (!this.l) {
                    return true;
                }

                VelocityTracker v2 = this.c;
                v2.computeCurrentVelocity(1000, ((float) this.e));
                int v2_1 = ((int) v2.getYVelocity(this.i));
                int v3 = this.a(arg8, this.i);
                if (this.i != v6) {
                    v3 = ((int) (arg8.getY(v3) - this.h));
                    if (Math.abs(v3) > this.k && Math.abs(v2_1) > this.d) {
                        if (v2_1 > 0 && v3 > 0) {
                            if (this.a != null) {
                                this.a.a(false);
                            }
                        } else if (v2_1 < 0 && v3 < 0) {
                            if (this.a != null) {
                                this.a.a(true);
                            }
                        } else if (this.a == null) {
                        } else {
                            this.a.a();
                        }
                    } else if (this.a == null) {
                    } else {
                        this.a.a();
                    }
                }

                this.i = v6;
                this.b();
                break;
            }
            case 5: {
                v0_1 = arg8.getActionIndex();
                this.g = arg8.getY(v0_1);
                this.f = arg8.getX(v0_1);
                this.i = arg8.getPointerId(v0_1);
                break;
            }
            case 6: {
                v0_1 = this.a(arg8, this.i);
                if (this.i == v6) {
                    return true;
                }

                this.g = arg8.getY(v0_1);
                this.f = arg8.getX(v0_1);
                break;
            }
        }

        return true;
    }

    public void setOnScrollListener(a arg1) {
        this.a = arg1;
    }

    public interface a {
        void a(boolean arg1);

        void a();

        void a(float arg1);
    }
}

